home *** CD-ROM | disk | FTP | other *** search
- // Copyright (c)1995 Ray Dream, Inc. All Rights Reserved.
- /* $Id: ShdrDll.cpp 1.2 1996/07/23 21:41:55 Damien Exp $ */
- //
- // Functions used by the DLL
- //
-
- #ifndef __SHDRDLL__
- #include "Shdrdll.h"
- #endif
-
- #ifndef __CHECKER__
- #include "Checker.h"
- #endif
-
- #ifndef __RAINBOW__
- #include "Rainbow.h"
- #endif
-
- #ifndef __SHDRFAC__
- #include "ShdrFac.h"
- #endif
-
- #ifndef __3DCOFAIL__
- #include "3DCoFail.h"
- #endif
-
- STDAPI DllInitRDCom(IShUtilities* shellUtilities) {
- InitCoFailure(shellUtilities);
- return S_OK;
- }
-
- //------------------------------------------------------------------------
- /*
- * DllGetClassObject
- *
- * Purpose:
- * Provides an IClassFactory for a given CLSID that this DLL is
- * registered to support. This DLL is placed under the CLSID
- * in the registration database as the InProcServer.
- *
- * Parameters:
- * clsID REFCLSID that identifies the class factory
- * desired. Since this parameter is passed this
- * DLL can handle any number of objects simply
- * by returning different class factories here
- * for different CLSIDs.
- *
- * riid REFIID specifying the interface the caller wants
- * on the class object, usually IID_ClassFactory.
- *
- * ppv LPVOID FAR* in which to return the interface
- * pointer.
- *
- * Return Value:
- * HRESULT NOERROR on success, otherwise an error code.
- */
-
- STDAPI DllGetClassObject(REFCLSID rclsid
- , REFIID riid, LPVOID FAR* ppv) {
- if ((!IsEqualCLSID(rclsid, CLSID_CheckerShader))
- &&(!IsEqualCLSID(rclsid, CLSID_RainbowShader)))
- return ResultFromScode(E_FAIL);
-
- //Check that we can provide the interface
- if (!IsEqualIID(riid, IID_IUnknown) && !IsEqualIID(riid, IID_IClassFactory))
- return ResultFromScode(E_NOINTERFACE);
-
- //Return our IClassFactory for the correct Shader objects
- if (IsEqualCLSID(rclsid,CLSID_CheckerShader))
- *ppv=(LPVOID) new CheckerClassFactory();
- else
- *ppv=(LPVOID) new RainbowClassFactory();
-
- if (*ppv == NULL)
- return ResultFromScode(E_OUTOFMEMORY);
-
- //AddRef the object through any interface we return
- ((LPUNKNOWN)*ppv)->AddRef();
-
- return NOERROR;
- }
-
-
- /*
- * DllCanUnloadNow
- *
- * Purpose:
- * Answers if the DLL can be freed, that is, if there are no
- * references to anything this DLL provides.
- *
- * Parameters:
- * None
- *
- * Return Value:
- * BOOL TRUE if nothing is using us, FALSE otherwise.
- */
-
- STDAPI DllCanUnloadNow() {
- SCODE sc;
-
- //Our answer is whether there are any object or locks
- sc=(0L==global_count_Obj && 0L==global_count_Lock) ? S_OK : S_FALSE;
- return ResultFromScode(sc);
- }
-
- //------------------------------------------------------------------------
- //Count number of objects and number of locks.
- long global_count_Obj = 0;
- long global_count_Lock = 0;
-
-